<%--
  Created by IntelliJ IDEA.
  User: guoshunw
  Date: 13-9-2
  Time: 上午10:02
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<tr>
    <td class="label">Description</td>
    <td colspan="3">

        <s:textarea id="description" name="description" theme="simple" value="%{req.description}"
                    disabled="true" cssStyle="width: 99%; height: 80px"
                    cssClass="viewProperties"/>
    </td>
</tr>
<tr>
    <td class="label">Attachments</td>
    <td rowspan=2 colspan="4">
        <div>
            <jsp:include page="attachments.jsp">
                <jsp:param name="context" value="viewDialog"/>
                <jsp:param name="uploadBrowserId"
                           value="uploadRequestAttachmentInViewDialog"/>
                <jsp:param name="gridId" value="requestAttachmentsGridInViewDialog"/>
                <jsp:param name="uploaderId"
                           value="requestAttachmentUploadInViewDialog"/>
                <jsp:param name="requestId"
                           value="${req.id}"/>
            </jsp:include>
        </div>
    </td>
</tr>
<tr>
    <td valign='top' align="right">
        <button id="uploadRequestAttachmentInViewDialog" style="width: 120px"
              <s:if test="%{guest}">disabled</s:if> ></button>
    </td>
</tr>


<script type="text/javascript">
    //    show attachments
    $(function () {

        var requestForm = $("div#tab_<s:property value='req.id'/>");
        global.updateIncludeAttributes = function (request) {
            var convertToGridData =
            {   page: 1, total: 100,
                rows: $(request.attachments).map(function (index, attachment) {
                    return {
                        id: attachment.id,
                        cell: [attachment.name, attachment.size, attachment.createTime]
                    }
                }).get()
            };
            var attachmentsGrid = $('#requestAttachmentsGridInViewDialog', requestForm);
            attachmentsGrid[0].addJSONData(convertToGridData);
        }
    });
</script>
